package tk.winshu.shortestpath.model;

import javax.imageio.ImageIO;
import java.awt.*;
import java.io.IOException;

/**
 * 节点状态信息
 *
 * @author winshu
 * @since 2019/10/19.
 */
public enum NodeStatus {

    /**
     * 焦点
     */
    FOCUSED(Color.CYAN, "node_focused.png"),
    /**
     * 起点
     */
    START(Color.MAGENTA, "node_start.png"),
    /**
     * 终点
     */
    END(Color.YELLOW, "node_end.png"),
    /**
     * 默认
     */
    DEFAULT(Color.WHITE, "node_default.png"),

    /**
     * 临时
     */
    TEMP(Color.RED, "node_default.png");

    NodeStatus(Color color, String image) {
        try {
            this.color = color;
            this.image = ImageIO.read(NodeStatus.class.getResource("/image/" + image));
        } catch (IOException e) {
            System.err.println("Can't load image: " + image);
        }
    }

    private Image image;

    private Color color;

    public Image getImage() {
        return image;
    }

    public Color getColor() {
        return color;
    }

    public boolean isDrawShape() {
        return !DEFAULT.equals(this) && !TEMP.equals(this);
    }
}
